<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
    </style>
</head>

<body>

    <script type="module">
        import * as THREE from './v136/three.module.js';

        // from '../../../build/three.module.js';  OrbitControls.js需要改变引用地址
        import { OrbitControls } from './v136/OrbitControls.js';

        // import { GLTFLoader } from './jsm/loaders/GLTFLoader.js';
        // import { RGBELoader } from './jsm/loaders/RGBELoader.js';
        // import { RoughnessMipmapper } from './jsm/utils/RoughnessMipmapper.js';
        console.log(`index.html 28 [THREE]`, THREE.REVISION);

        // 创建场景
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer();

        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        // 添加坐标系
        const axesHelper = new THREE.AxesHelper(50);
        scene.add(axesHelper);

        // 添加一个立方体
        const geometry = new THREE.BoxGeometry(2, 2, 2);
        const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
        const cube = new THREE.Mesh(geometry, material);
        scene.add(cube);

        camera.position.set(5, 5, 5); // 设置相机位置
        camera.lookAt(0, 0, 0); // 相机指向坐标原点

        const controls = new OrbitControls(camera, renderer.domElement);

        // 动画循环
        function animate() {
            requestAnimationFrame(animate);
            cube.rotation.x += 0.01;
            cube.rotation.y += 0.01;
            controls.update(); // 更新控制器
            renderer.render(scene, camera);
        }

        animate();
    </script>
</body>

</html>